<?php

declare(strict_types=1);

namespace App\Model\Users;



use App\Model\Model;

/**
 * @property int $id
 * @property int $send_uid 发送用户uid, 0表示系统发送
 * @property int $to_uid 接受人uid
 * @property int $type 消息类型，1：申请好友，2：申请加入群
 * @property string $contents 消息内容
 * @property string $results_contents 处理结果
 * @property int $status 状态 1： 待处理，2：已同意，3：已拒绝
 * @property string $files 附件信息
 * @property \Carbon\Carbon $created_at 申请时间
 * @property \Carbon\Carbon $updated_at 更新时间
 */
class UserMessages extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'user_messages';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'send_uid', 'to_uid', 'type', 'contents', 'results_contents', 'status', 'files', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'send_uid' => 'integer', 'to_uid' => 'integer', 'type' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];



    public function sendUser()
    {
        return $this->hasOne(User::class,'id','send_uid')->select(['id','account','nick_name','remark','avatar']);
    }

}
